package qx.hyj.demos.service.impl;

import org.springframework.cache.annotation.Cacheable;
import qx.hyj.demos.entity.User;
import qx.hyj.demos.mapper.Usermapper;
import qx.hyj.demos.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private Usermapper usermapper;

    @Override
    @Cacheable("addUser")
    public Integer addUser(User user) {
        Integer result = usermapper.addUser(user);
        System.out.println(result);
        return result;
    }

    @Override
    @Cacheable("getUser")
    public User getUser(Integer id) {
        User user = usermapper.getUser(id);
        System.out.println(user);
        return user;
    }

    @Override
    public User getUserByName(String userName) {
        User user = usermapper.getIdByName(userName);
        System.out.println(user);
        return user;
    }
}
